// this script is a local post-commit hook script.

var objArgs,num;

objArgs = WScript.Arguments;
num = objArgs.length;
if (num != 6)
{
    WScript.Echo("Usage: [CScript | WScript] PostCommit.js path/to/pathsfile depth path/to/messagefile revision error path/to/CWD ");
    WScript.Quit(1);
}

var paths = readPaths(objArgs(0));
var message = "list of paths selected for commit:\n";
var i = 0;
while (i < paths.length)
{
	message = message + paths[i] + "\n";
	i = i + 1;
}
message = message + "depth is: " + objArgs(1) + "\n";
message = message + "path of message file is: " + objArgs(2) + "\n";
message = message + "result revision is: " + objArgs(3) + "\n";
message = message + "file containing error message is: " + objArgs(4) + "\n";
message = message + "CWD is: " + objArgs(5) + "\n";

WScript.Echo(message);
WScript.Quit(0);


function readPaths(path)
{
	var retPaths = new Array();
	var fs = new ActiveXObject("Scripting.FileSystemObject");
	if (fs.FileExists(path))
	{
		var a = fs.OpenTextFile(path, 1, false);
		var i = 0;
		while (!a.AtEndOfStream)
		{
			var line = a.ReadLine();
			retPaths[i] = line;
			i = i + 1;
		}
		a.Close();
	}
	return retPaths;
	
}